package com.hexinfo.dmpro.component.file.transfer.model;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.net.ftp.FTPClient;
import org.springframework.validation.annotation.Validated;

@Data
@Validated
@Accessors(chain = true)
@NoArgsConstructor
public class FileTransfer {

    public FileTransfer(String transferType, String server, Integer port, String user, String password){
        this.transferType = transferType;
        this.server = server;
        this.port = port;
        this.user = user;
        this.password = password;
    }

    /** 文件传输方式(FTP/SFTP) **/
    private String transferType;

    /** 服务器server **/
    private String server;

    /** 服务器端口 **/
    private Integer port;

    /** 服务器用户 **/
    private String user;

    /** 服务器密码 **/
    private String password;

    /** FtpClient **/
    private FTPClient ftpClient;

    /** 本地文件目录 **/
    private String localDir;

    /** 远端文件目录 **/
    private String remoteDir;

    /** 文件名 **/
    private String fileName;

    /** 本地文件路径 **/
    private String localFilePath;

    /** 远端文件路径 **/
    private String remoteFilePath;

    /** 远端文件备份名 **/
    private String remoteFileNewName;

    /** 远端文件备份路径 **/
    private String remoteFileNewPath;

    public String getLocalFilePath() {
        return localDir + "/" + fileName;
    }

    public String getRemoteFilePath() {
        return remoteDir + "/" + fileName;
    }

    public String getRemoteFileNewPath() {
        return remoteDir + "/" + remoteFileNewName;
    }
}
